#include <unistd.h>
#include <cassert>
#include <string>
#include <functional>
#include "./../../source/server.hpp"
#include "./../../source/http/http.hpp"

int main()
{
    Socket cli;
    cli.ClinetCreate("127.0.0.1", 8889);
    std::string req;
    std::string body;
    Util::ReadFile("./test.txt", &body);
    req += "PUT /Put HTTP/1.1\r\n";
    req += "Connection: keep-alive\r\n";
    req += "Content-Length: ";
    req += std::to_string(body.size());
    req += "\r\n";
    req += "\r\n";
    assert(cli.Send(req.c_str(), req.size()) != -1);
    assert(cli.Send(body.c_str(), body.size()) != -1);
    char buff[1024] = { 0 };
    ssize_t n = cli.Recv(buff, 1023);
    assert(n != -1);
    buff[n] = 0;
    std::cout << "[" << buff << "]" << std::endl;

    while (true) { sleep(1); }
    return 0;
}